package cn.snowheart

import junit.textui.TestRunner

/**
 * Groovy 测试
 * 继承GroovyTestCase类，所有的void成员方法均可用来测试
 * GroovyTestSuite类可用于将所有测试案例封装起来
 *
 * @author liuwanxiang
 * @version 2019/05/31
 */
class TestExample {

    static void main(String[] args) {
        def suite = new GroovyTestSuite()
        suite.addTestSuite(UserTests.class)
        suite.addTestSuite(PersonTests.class)
        TestRunner.run(suite)
    }

    static class User {
        String name
        int uid

        def display() {
            return name + uid
        }
    }

}


class UserTests extends GroovyTestCase {
    void testDisplay() {
        def user = new TestExample.User()
        user.name = "Name"
        user.uid = 1001
        assertEquals(user.display(), "Name1001")
    }
}

class PersonTests extends GroovyTestCase {
    void testDisplay() {
        def user = new TestExample.User()
        user.name = "Name"
        user.uid = 1001
        assertEquals(user.display(), "Name1001")
    }
}